<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Class: Spec::DSL::ExampleShouldRaiseHandler</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
  <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
  <script type="text/javascript">
  // <![CDATA[

  function popupCode( url ) {
    window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
  }

  function toggleCode( id ) {
    if ( document.getElementById )
      elem = document.getElementById( id );
    else if ( document.all )
      elem = eval( "document.all." + id );
    else
      return false;

    elemStyle = elem.style;
    
    if ( elemStyle.display != "block" ) {
      elemStyle.display = "block"
    } else {
      elemStyle.display = "none"
    }

    return true;
  }
  
  // Make codeblocks hidden by default
  document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
  
  // ]]>
  </script>

</head>
<body>



    <div id="classHeader">
        <table class="header-table">
        <tr class="top-aligned-row">
          <td><strong>Class</strong></td>
          <td class="class-name-in-header">Spec::DSL::ExampleShouldRaiseHandler</td>
        </tr>
        <tr class="top-aligned-row">
            <td><strong>In:</strong></td>
            <td>
                <a href="../../../files/vendor/plugins/rspec/lib/spec/dsl/example_should_raise_handler_rb.html">
                vendor/plugins/rspec/lib/spec/dsl/example_should_raise_handler.rb
                </a>
        <br />
            </td>
        </tr>

        <tr class="top-aligned-row">
            <td><strong>Parent:</strong></td>
            <td>
                <a href="../../Object.html">
                Object
               </a>
            </td>
        </tr>
        </table>
    </div>
  <!-- banner header -->

  <div id="bodyContent">



  <div id="contextContent">



   </div>

    <div id="method-list">
      <h3 class="section-bar">Methods</h3>

      <div class="name-list">
      <a href="#M000349">build_message</a>&nbsp;&nbsp;
      <a href="#M000347">determine_error_class</a>&nbsp;&nbsp;
      <a href="#M000348">determine_error_message</a>&nbsp;&nbsp;
      <a href="#M000350">error_matches?</a>&nbsp;&nbsp;
      <a href="#M000351">handle</a>&nbsp;&nbsp;
      <a href="#M000346">new</a>&nbsp;&nbsp;
      </div>
    </div>

  </div>


    <!-- if includes -->

    <div id="section">





      


    <!-- if method_list -->
    <div id="methods">
      <h3 class="section-bar">Public Class methods</h3>

      <div id="method-M000346" class="method-detail">
        <a name="M000346"></a>

        <div class="method-heading">
          <a href="#M000346" class="method-signature">
          <span class="method-name">new</span><span class="method-args">(file_and_line_number, opts)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000346-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000346-source">
<pre>
   <span class="ruby-comment cmt"># File vendor/plugins/rspec/lib/spec/dsl/example_should_raise_handler.rb, line 4</span>
4:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">file_and_line_number</span>, <span class="ruby-identifier">opts</span>)
5:         <span class="ruby-ivar">@file_and_line_number</span> = <span class="ruby-identifier">file_and_line_number</span>
6:         <span class="ruby-ivar">@options</span> = <span class="ruby-identifier">opts</span>
7:         <span class="ruby-ivar">@expected_error_class</span> = <span class="ruby-identifier">determine_error_class</span>(<span class="ruby-identifier">opts</span>)
8:         <span class="ruby-ivar">@expected_error_message</span> = <span class="ruby-identifier">determine_error_message</span>(<span class="ruby-identifier">opts</span>)
9:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <h3 class="section-bar">Public Instance methods</h3>

      <div id="method-M000349" class="method-detail">
        <a name="M000349"></a>

        <div class="method-heading">
          <a href="#M000349" class="method-signature">
          <span class="method-name">build_message</span><span class="method-args">(exception=nil)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000349-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000349-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/rspec/lib/spec/dsl/example_should_raise_handler.rb, line 32</span>
32:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">build_message</span>(<span class="ruby-identifier">exception</span>=<span class="ruby-keyword kw">nil</span>)
33:         <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@expected_error_message</span>.<span class="ruby-identifier">nil?</span>
34:           <span class="ruby-identifier">message</span> = <span class="ruby-node">&quot;example block expected #{@expected_error_class.to_s}&quot;</span>
35:         <span class="ruby-keyword kw">else</span>
36:           <span class="ruby-identifier">message</span> = <span class="ruby-node">&quot;example block expected #{@expected_error_class.new(@expected_error_message.to_s).inspect}&quot;</span>
37:         <span class="ruby-keyword kw">end</span>
38:         <span class="ruby-identifier">message</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot; but raised #{exception.inspect}&quot;</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">exception</span>
39:         <span class="ruby-identifier">message</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-value str">&quot; but nothing was raised&quot;</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">exception</span>
40:         <span class="ruby-identifier">message</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-value str">&quot;\n&quot;</span>
41:         <span class="ruby-identifier">message</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-ivar">@file_and_line_number</span>
42:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000347" class="method-detail">
        <a name="M000347"></a>

        <div class="method-heading">
          <a href="#M000347" class="method-signature">
          <span class="method-name">determine_error_class</span><span class="method-args">(opts)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000347-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000347-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/rspec/lib/spec/dsl/example_should_raise_handler.rb, line 11</span>
11:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">determine_error_class</span>(<span class="ruby-identifier">opts</span>)
12:         <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">candidate</span> = <span class="ruby-identifier">opts</span>[<span class="ruby-identifier">:should_raise</span>]
13:           <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">candidate</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Class</span>)
14:             <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">candidate</span>
15:           <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">candidate</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Array</span>)
16:             <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">candidate</span>[<span class="ruby-value">0</span>]
17:           <span class="ruby-keyword kw">else</span>
18:             <span class="ruby-keyword kw">return</span> <span class="ruby-constant">Exception</span>
19:           <span class="ruby-keyword kw">end</span>
20:         <span class="ruby-keyword kw">end</span>
21:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000348" class="method-detail">
        <a name="M000348"></a>

        <div class="method-heading">
          <a href="#M000348" class="method-signature">
          <span class="method-name">determine_error_message</span><span class="method-args">(opts)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000348-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000348-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/rspec/lib/spec/dsl/example_should_raise_handler.rb, line 23</span>
23:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">determine_error_message</span>(<span class="ruby-identifier">opts</span>)
24:         <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">candidate</span> = <span class="ruby-identifier">opts</span>[<span class="ruby-identifier">:should_raise</span>]
25:           <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">candidate</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Array</span>)
26:             <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">candidate</span>[<span class="ruby-value">1</span>]
27:           <span class="ruby-keyword kw">end</span>
28:         <span class="ruby-keyword kw">end</span>
29:         <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">nil</span>
30:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000350" class="method-detail">
        <a name="M000350"></a>

        <div class="method-heading">
          <a href="#M000350" class="method-signature">
          <span class="method-name">error_matches?</span><span class="method-args">(error)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000350-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000350-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/rspec/lib/spec/dsl/example_should_raise_handler.rb, line 44</span>
44:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">error_matches?</span>(<span class="ruby-identifier">error</span>)
45:         <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">error</span>.<span class="ruby-identifier">kind_of?</span>(<span class="ruby-ivar">@expected_error_class</span>)
46:         <span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@expected_error_message</span>.<span class="ruby-identifier">nil?</span>
47:           <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@expected_error_message</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Regexp</span>)
48:             <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">error</span>.<span class="ruby-identifier">message</span> <span class="ruby-operator">=~</span> <span class="ruby-ivar">@expected_error_message</span>
49:           <span class="ruby-keyword kw">else</span>
50:             <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">false</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">error</span>.<span class="ruby-identifier">message</span> <span class="ruby-operator">==</span> <span class="ruby-ivar">@expected_error_message</span>
51:           <span class="ruby-keyword kw">end</span>
52:         <span class="ruby-keyword kw">end</span>
53:         <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">true</span>
54:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000351" class="method-detail">
        <a name="M000351"></a>

        <div class="method-heading">
          <a href="#M000351" class="method-signature">
          <span class="method-name">handle</span><span class="method-args">(errors)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000351-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000351-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/rspec/lib/spec/dsl/example_should_raise_handler.rb, line 56</span>
56:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">handle</span>(<span class="ruby-identifier">errors</span>)
57:         <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@expected_error_class</span>
58:           <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">errors</span>.<span class="ruby-identifier">empty?</span>
59:             <span class="ruby-identifier">errors</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-constant">Spec</span><span class="ruby-operator">::</span><span class="ruby-constant">Expectations</span><span class="ruby-operator">::</span><span class="ruby-constant">ExpectationNotMetError</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">build_message</span>)
60:           <span class="ruby-keyword kw">else</span>
61:             <span class="ruby-identifier">error_to_remove</span> = <span class="ruby-identifier">errors</span>.<span class="ruby-identifier">detect</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">error</span><span class="ruby-operator">|</span>
62:               <span class="ruby-identifier">error_matches?</span>(<span class="ruby-identifier">error</span>)
63:             <span class="ruby-keyword kw">end</span>
64:             <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">error_to_remove</span>.<span class="ruby-identifier">nil?</span>
65:               <span class="ruby-identifier">errors</span>.<span class="ruby-identifier">insert</span>(<span class="ruby-value">0</span>,<span class="ruby-constant">Spec</span><span class="ruby-operator">::</span><span class="ruby-constant">Expectations</span><span class="ruby-operator">::</span><span class="ruby-constant">ExpectationNotMetError</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">build_message</span>(<span class="ruby-identifier">errors</span>[<span class="ruby-value">0</span>])))
66:             <span class="ruby-keyword kw">else</span>
67:               <span class="ruby-identifier">errors</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">error_to_remove</span>)
68:             <span class="ruby-keyword kw">end</span>
69:           <span class="ruby-keyword kw">end</span>
70:         <span class="ruby-keyword kw">end</span>
71:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>


    </div>


  </div>


<div id="validator-badges">
  <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>

</body>
</html>